<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <form id="my-form" class="am-form tpl-form-line-form" method="post">
                    <div class="widget-body">
                        <fieldset>
                            <div class="widget-head am-cf">
                                <div class="widget-title am-fl">添加预约类型</div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 类型名称 </label>
                                <div class="am-u-sm-9 am-u-md-6 am-u-lg-5 am-u-end">
                                    <input type="text" class="tpl-form-input" name="type[name]"
                                           value="<?= $model['name'] ?>" placeholder="请输入等级名称" required>
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 服务人员个数 </label>
                                <div class="am-u-sm-9 am-u-md-6 am-u-lg-5 am-u-end">
                                    <input type="text" class="tpl-form-input" name="type[count]"
                                           value="<?= $model['count'] ?>" placeholder="请输入服务人员个数" required>
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 提成方案 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <label class="am-radio-inline">
                                        <input class="checkRadio" id="radio" type="radio" name="type[type]" value="0" data-am-ucheck
                                            <?= $model['type'] == 0 ? 'checked' : '' ?>>>
                                        清洗师傅
                                    </label>
                                    <label class="am-radio-inline">
                                        <input class="checkRadio" id="radio" type="radio" name="type[type]" value="1" data-am-ucheck
                                            <?= $model['type'] == 1 ? 'checked' : '' ?>>>
                                        维修师傅
                                    </label>
                                    <label class="am-radio-inline">
                                        <input class="checkRadio" id="radio" type="radio" name="type[type]" value="2" data-am-ucheck
                                            <?= $model['type'] == 2 ? 'checked' : '' ?>>>
                                        保洁阿姨
                                    </label>
                                </div>
                            </div>

                            <div class="am-form-group radio1">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 固定提成 </label>
                                <div class="am-u-sm-9 am-u-md-6 am-u-lg-5 am-u-end">
                                    <input type="text" class="tpl-form-input" name="type[fixation]"
                                           value="<?= $model['fixation'] ?>" placeholder="固定提成">
                                </div>
                            </div>

                            <div class="am-form-group radio2"  style="display:none">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 比例提成 </label>
                                <div class="am-u-sm-9 am-u-md-6 am-u-lg-5 am-u-end">
                                    <input type="text" class="tpl-form-input" name="type[ratio]"
                                           value="<?= $model['ratio'] ?>" placeholder="按比例提成">
                                </div>
                            </div>

                            <div class="am-form-group radio12">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 订单奖励 </label>
                                <div class="am-u-sm-9 am-u-md-6 am-u-lg-5 am-u-end">
                                    <input type="text" class="tpl-form-input" name="type[award]"
                                           value="<?= $model['award'] ?>" placeholder="每一订单奖励">
                                </div>
                            </div>

                            <div class="am-form-group radio12">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 远程费 </label>
                                <div class="am-u-sm-9 am-u-md-6 am-u-lg-5 am-u-end">
                                    <input type="text" class="tpl-form-input" name="type[remote_fee]"
                                           value="<?= $model['remote_fee'] ?>" placeholder="远程服务费">
                                </div>
                            </div>

                            <div class="am-form-group radio3"  style="display:none">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 提成 </label>
                                <div class="am-u-sm-9 am-u-md-6 am-u-lg-5 am-u-end">
                                    <input type="text" class="tpl-form-input" name="type[commission]"
                                           value="<?= $model['commission'] ?>" placeholder="基本工资">
                                </div>
                            </div>

                            <div class="am-form-group radio3"  style="display:none">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 超出时长 </label>
                                <div class="am-u-sm-9 am-u-md-6 am-u-lg-5 am-u-end">
                                    <input type="text" class="tpl-form-input" name="type[beyond_time]"
                                           value="<?= $model['beyond_time'] ?>" placeholder="超过XX小时">
                                </div>
                            </div>

                            <div class="am-form-group radio3"  style="display:none">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 每小时提成 </label>
                                <div class="am-u-sm-9 am-u-md-6 am-u-lg-5 am-u-end">
                                    <input type="text" class="tpl-form-input" name="type[time_money]"
                                           value="<?= $model['time_money'] ?>" placeholder="每小时提成XX">
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 类型状态 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <label class="am-radio-inline">
                                        <input type="radio" name="type[status]" value="1" data-am-ucheck
                                            <?= $model['status'] == 1 ? 'checked' : '' ?>>
                                        启用
                                    </label>
                                    <label class="am-radio-inline">
                                        <input type="radio" name="type[status]" value="0" data-am-ucheck
                                            <?= $model['status'] == 0 ? 'checked' : '' ?>>
                                        禁用
                                    </label>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <div class="am-u-sm-9 am-u-sm-push-3 am-margin-top-lg">
                                    <button type="submit" class="j-submit am-btn am-btn-secondary"> 提交
                                    </button>
                                </div>
                            </div>
                        </fieldset>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<script src="assets/store/js/select.data.js?v=<?= $version ?>"></script>
<!-- 用户列表模板 -->
<script id="tpl-user-item" type="text/template">
    {{ each $data }}
    <div class="file-item">
        <a href="{{ $value.avatarUrl }}" title="{{ $value.nickName }} (ID:{{ $value.user_id }})" target="_blank">
            <img src="{{ $value.avatarUrl }}">
        </a>
        <input type="hidden" name="type[service_id]" value="{{ $value.user_id }}">
    </div>
    {{ /each }}
</script>

<script>
    $(function () {
        // 选择用户
        $('.j-selectUser').click(function () {
            var $userList = $('.user-list');
            $.selectData({
                title: '选择用户',
                uri: 'user/lists_service',
                dataIndex: 'user_id',
                done: function (data) {
                    var user = [data[0]];
                    $userList.html(template('tpl-user-item', user));
                }
            });
        });

        /**
         * 表单验证提交
         * @type {*}
         */
        $('#my-form').superForm();
        $('.checkRadio').on('click',function(){
            // console.log($(this).val())
            if($(this).val() == 0){
                $('.radio1').show();
                $('.radio12').show();
                $('.radio2').hide();
                $('.radio3').hide();
            }else if($(this).val() == 1){
                $('.radio1').hide();
                $('.radio12').show();
                $('.radio2').show();
                $('.radio3').hide();
            }else{
                $('.radio1').hide();
                $('.radio12').hide();
                $('.radio2').hide();
                $('.radio3').show();
            }
        })

    });
</script>
